package com.gdufe.firesafe.model.dto;

import lombok.Data;

@Data
public class InspectionDTO {
    /**
     * 房屋id
     */
    private Integer houseId;
    /**
     * 安全检查的照片地址
     */
    private String photos;
    /**
     * 通道疏通情况，等级0-3，越高越通畅
     */
    private Integer passageUnblockStatus;
    /**
     * 烟雾检测器电池电量充足
     */
    private Boolean detectorElectricity;
    /**
     * 烟雾检测器自检功能正常
     */
    private Boolean detectorSelfTest;
    /**
     * 烟雾检测器无故障报警记录
     */
    private Boolean detectorNoError;
    /**
     * 燃气管道无泄漏
     */
    private Boolean gasNoLeakage;
    /**
     * 燃气表读数正常
     */
    private Boolean gasMeterStatus;
    /**
     * 自动切断阀功能有效
     */
    private Boolean gasAutomaticShutOff;
    /**
     * 电路无故障
     */
    private Boolean circuitStatus;
    /**
     * 电气设备绝缘良好
     */
    private Boolean electricalInsulation;
    /**
     * 备用电源工作正常
     */
    private Boolean standbyPower;
    /**
     * 负载分配合理
     */
    private Boolean electricalLoad;
    /**
     * 接地保护完善
     */
    private Boolean electricalGrounding;
    /**
     * 灭火器铅封完好
     */
    private Boolean extinguisherLeadSealing;
    /**
     * 灭火器压力良好
     */
    private Boolean extinguisherPressure;
    /**
     * 灭火器无明显物理损坏
     */
    private Boolean extinguisherDamaged;
    /**
     * 灭火器未过期
     */
    private Boolean extinguisherExpired;
    /**
     * 总结
     */
    private String summary;

    //计算总分
    public double calculateScore() {
        double score = 0;
        score+= passageUnblockStatus;
        fireExtinguisherStatus=0;
        if (this.extinguisherLeadSealing) fireExtinguisherStatus++;
        if (this.extinguisherPressure) fireExtinguisherStatus++;
        if (this.extinguisherDamaged) fireExtinguisherStatus++;
        if (this.extinguisherExpired) fireExtinguisherStatus++;
        score+=fireExtinguisherStatus;

        smokeDetectorStatus=0;
        if (this.detectorElectricity) smokeDetectorStatus++;
        if (this.detectorSelfTest) smokeDetectorStatus++;
        if (this.detectorNoError) smokeDetectorStatus++;
        score+=smokeDetectorStatus;

        gasStatus=0;
        if (this.gasNoLeakage) gasStatus++;
        if (this.gasMeterStatus) gasStatus++;
        if (this.gasAutomaticShutOff) gasStatus++;
        score+=gasStatus;

        electricity=0;
        if (this.circuitStatus) electricity++;
        if (this.electricalInsulation) electricity++;
        if (this.standbyPower) electricity++;
        if (this.electricalLoad) electricity++;
        if (this.electricalGrounding) electricity++;
        score+=electricity;

        score=score/18*100;
        return score;
    }

    //计算得出，不需要传入
    /**
     * 灭火器状态
     */
    private Integer fireExtinguisherStatus;
    /**
     * 烟雾检测器状态
     */
    private Integer smokeDetectorStatus;
    /**
     * 燃气情况
     */
    private Integer gasStatus;
    /**
     * 电力系统情况
     */
    private Integer electricity;
}
